﻿using System;
using System.Linq;
using System.Web.Mvc;
using AutoMapper;
using App.Interface;
using Domain.Entidades;
using System.Net;
using Services;

namespace SiteCredivale.Controllers
{
    public class MobileController : Controller
    {


        public MobileController()
        {


        }

        public ActionResult Ambiente(string tipo)
        {
            FtpWebRequest objFTP = null;
            FtpWebResponse response = null;
            try
            {
              
                switch (tipo)
                {
                    case "and":
                        objFTP = Generica.FTPDetail_mobile("android.apk");
                        objFTP.Method = WebRequestMethods.Ftp.DownloadFile;
                         response = (FtpWebResponse)objFTP.GetResponse();
                        return File(response.GetResponseStream(), "application/vnd.android.package-archive", "SICOOBCREDIVALE_android.apk");
                    case "ios":
                        objFTP = Generica.FTPDetail_mobile("Android.apk");
                        objFTP.Method = WebRequestMethods.Ftp.DownloadFile;
                        response = (FtpWebResponse)objFTP.GetResponse();
                        return File(response.GetResponseStream(), "application/pdf", "Android.apk");

                    default :
                        return null;
                }


              

                

            }




            catch (Exception ex)
            {

                TempData["msg_err"] = ex.Message;
                return RedirectToAction("erro", "Home");
            }

        }



    }
}
